package com.pp.controller;

import com.pp.common.pojo.User;
import com.pp.common.vo.SysResult;
import com.pp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/useradd")
    //传进来一个User对象,(from表单的数据)通过@RequestBody进行封装到User类
    public SysResult useradd(@RequestBody User user){
        //调用service的接口方法进行数据处理
        String useradd = userService.useradd(user);

        if("成功".equals(useradd)) {
            return SysResult.success();
        }
        return SysResult.fail();


    }
}
